package com.project.entity.sys;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.UniqueConstraint;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

/**
 * 系统权限
 * @author
 */
@Entity
@Table(name="S_PERMISSIONS")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@DynamicInsert
@DynamicUpdate
public class Permissions extends BaseEntity implements Serializable {

	private static final long serialVersionUID = 1L;

	@Column(name = "parent_id")
	private Integer parentId;//父ID
	@Column(name = "permissions_name", length = 50)
	private String permissionsName;//权限名称
	@Column(name = "element", length = 100,unique = true,nullable = false)
	private String element;//权限标签
	@Column(name = "status", length = 1)
	private String status;//是否启用（0：不启用；1：启用）
	@Column(name = "rmk", length = 100)
	private String rmk;//备注
	@Column(name = "create_user", length = 20)
	private String create_user;//创建人
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "create_time", length = 19)
	private Date createTime;//创建时间
	@Column(name = "update_user", length = 20)
	private String updateUser;//修改人
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "update_time", length = 19)
	private Date updateTime;//修改时间
	
	@ManyToMany
	@JoinTable(name="S_ROLE_PERMISSIONS", 
    		joinColumns = { @JoinColumn(name = "PERMISSIONS_ID",nullable = false) }, 
    		inverseJoinColumns = { @JoinColumn(name = "ROLE_ID",nullable = false) },
    		uniqueConstraints = {@UniqueConstraint(columnNames={"ROLE_ID","PERMISSIONS_ID"})})
	List<Role> roles = new ArrayList<Role>();//角色
	
	public Integer getParentId() {
		return parentId;
	}
	public void setParentId(Integer parentId) {
		this.parentId = parentId;
	}
	
	public String getPermissionsName() {
		return permissionsName;
	}
	public void setPermissionsName(String permissionsName) {
		this.permissionsName = permissionsName;
	}
	
	public String getElement() {
		return element;
	}
	public void setElement(String element) {
		this.element = element;
	}
	
	public String getStatus() {
		return status;
	}
	public void setStatus(String status) {
		this.status = status;
	}
	
	public String getRmk() {
		return rmk;
	}
	public void setRmk(String rmk) {
		this.rmk = rmk;
	}
	
	public String getCreate_user() {
		return create_user;
	}
	public void setCreate_user(String create_user) {
		this.create_user = create_user;
	}
	
	public Date getCreateTime() {
		return createTime;
	}
	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}
	
	public String getUpdateUser() {
		return updateUser;
	}
	public void setUpdateUser(String updateUser) {
		this.updateUser = updateUser;
	}
	
	public Date getUpdateTime() {
		return updateTime;
	}
	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}
	
	public List<Role> getRoles() {
		return roles;
	}
	public void setRoles(List<Role> roles) {
		this.roles = roles;
	}
	
}
